home *** CD-ROM | disk | FTP | other *** search
- #include "PicMDEF.h"
-
- /* Build a new Picture Menu
- Takes three arguments:
- title: Title of menu, will be truncated to 31 chars if longer
- pic: PicHandle for the menu picture
- nrct: Hanlde to an nrct defining the hot areas
-
- This routine assumes you'll be using HyperCard palettes and sets the
- tBarHeight field to 12, change if using another window style
- Sets the two hightlight fields to zero so no highlighting takes place
- */
- MenuHandle NewPicMenu(title, pic, nrct)
- Str31 title; PicHandle pic; nrctHand nrct;
- { PicMenuHandle mh;
- register PicMenuPtr mp;
- register int id;
-
- /* mh = (PicMenuHandle)NewHandle(sizeof(PicMenu));
- HLock(mh);
- mp = *mh; */
- asm
- { move.l #sizeof(PicMenu),d0
- _NewHandle
- move.l a0,mh
- _HLock
- move.l (a0),mp
- }
-
- /* Apple's algorithm for free id */
- id = 1023;
- while( GetMHandle(++id) );
- mp->menuID = id;
-
- asm
- { /* copy title */
- move.l title,a0
- lea OFFSET(PicMenu,menuTitle)(mp),a1
- moveq #32,d0
- _BlockMove
- /* truncate it too long */
- move.b OFFSET(PicMenu,menuTitle)(mp),d0
- cmp.b #31,d0
- ble.s @lenOk
- move.b #31,OFFSET(PicMenu,menuTitle)(mp)
- lenOk:
- }
-
- /* fill in other fields */
- mp->enableFlags = -1;
- mp->menuPic = pic;
- mp->nrcts = nrct;
- mp->hiOne = mp->hiTwo = 0;
- mp->tBarHeight = 12; /* height of HC palette title bar */
- mp->menuProc = GetNamedResource('MDEF', "\pPicture MDEF");
-
- asm
- { move.l mh,a0
- _HUnlock
- }
-
- /* get Menu Manager to fill in size fields */
- CalcMenuSize((MenuHandle)mh);
-
- return (MenuHandle)mh;
- }
-
- /* Dispose a Picture Menu
- This version releases the MDEF - don't do this if you have
- multiple Picture menus!
- */
- void DisposePicMenu(pm) MenuHandle pm;
- { asm
- { move.l pm,a0
- move.l (a0),a1
- move.l OFFSET(PicMenu, menuProc)(a1),-(a7)
- _DisposHandle
- _ReleaseResource
- }
- }